﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;

namespace S7.Windows.Reservations
{
    /// <summary>
    /// Interaction logic for AddAReservation.xaml
    /// </summary>
    public partial class AddAReservation : Window
    {
        public AddAReservation()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Booking booking = new Booking();
            // tbCustomerName.Text
            //booking.BookingTime = tbBookingTime.Text;
            //tbBookingDate.Text
            //tbTable.Text
            //tbMoneyCharged.Text
            //tbBookingStatus.Text
            //dtpBookingDate.ShofEnta :D
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Thread thr = new Thread(new ThreadStart(() =>
            {
                Customer.lstCustomers = Customer.Search();
                tbCustomerName.Dispatcher.Invoke(new ThreadStart(() =>
                    {
                        foreach (var cust in Customer.lstCustomers)
                        {
                            tbCustomerName.Items.Add(cust.UserName);
                        }
                    }), null);
            }));
            thr.IsBackground = true;
            try
            {
                thr.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Customer.lstCustomers = null;
        }
    }
}
